package com.wecan.base.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.wecan.base.constants.CommonConstants;

/**
 * @Author liuzhihao
 * @Date 2022.03.18
 * @Version ${version}
 * @Description ${description}
 */
public enum OssUploadType {

    IMAGE(1, "knowledge/img/", CommonConstants.OSS_HTTPS_URL),
    COUPON_PROMOTE_IMAGE(2, "system/img/couponpromote/", CommonConstants.OSS_URL),
    BANNER_IMAGE(3, "system/img/banner/", CommonConstants.OSS_URL),
    USER_AVATAR(4, "user/avatar/", CommonConstants.OSS_URL),
    WITHDRAW_IMAGE(5, "withdraw/", CommonConstants.OSS_HTTPS_URL),
    KNOWLEDGE_VIDEO(6, "knowledge/video/", CommonConstants.OSS_HTTPS_URL),
    KNOWLEDGE_AUDIO(7, "knowledge/audio/", CommonConstants.OSS_HTTPS_URL),
    COMPLAIN(8, "complain", CommonConstants.OSS_HTTPS_URL);

    @EnumValue
    @JsonValue
    private final int code;

    private final String desc;

    private final String protocol;

    OssUploadType(int code, String desc, String protocol) {
        this.code = code;
        this.desc = desc;
        this.protocol = protocol;
    }

    public String getDesc() {
        return desc;
    }

    public int getCode() {
        return code;
    }

    public String getProtocol() {
        return protocol;
    }

    public static OssUploadType getNameByCode(int code) {
        for (OssUploadType value : OssUploadType.values()) {
            if (value.getCode() == code) {
                return value;
            }
        }
        return null;
    }
}
